package com.nmsl.registration.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.registration.domain.skxMedicalRecord;
import com.nmsl.registration.service.IskxMedicalRecordService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 病历信息Controller
 * 
 * @author skx
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/registration/skxmedicalrecord")
public class skxMedicalRecordController extends BaseController
{
    @Autowired
    private IskxMedicalRecordService skxMedicalRecordService;

    /**
     * 查询病历信息列表
     */
    @PreAuthorize("@ss.hasPermi('registration:skxmedicalrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(skxMedicalRecord skxMedicalRecord)
    {
        startPage();
        List<skxMedicalRecord> list = skxMedicalRecordService.selectskxMedicalRecordList(skxMedicalRecord);
        return getDataTable(list);
    }

    /**
     * 导出病历信息列表
     */
    @PreAuthorize("@ss.hasPermi('registration:skxmedicalrecord:export')")
    @Log(title = "病历信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, skxMedicalRecord skxMedicalRecord)
    {
        List<skxMedicalRecord> list = skxMedicalRecordService.selectskxMedicalRecordList(skxMedicalRecord);
        ExcelUtil<skxMedicalRecord> util = new ExcelUtil<skxMedicalRecord>(skxMedicalRecord.class);
        util.exportExcel(response, list, "病历信息数据");
    }

    /**
     * 获取病历信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxmedicalrecord:query')")
    @GetMapping(value = "/{visitRecordId}")
    public AjaxResult getInfo(@PathVariable("visitRecordId") Long visitRecordId)
    {
        return success(skxMedicalRecordService.selectskxMedicalRecordByMedicalRecordId(visitRecordId));
    }

    /**
     * 新增病历信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxmedicalrecord:add')")
    @Log(title = "病历信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody skxMedicalRecord skxMedicalRecord)
    {
        return toAjax(skxMedicalRecordService.insertskxMedicalRecord(skxMedicalRecord));
    }

    /**
     * 修改病历信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxmedicalrecord:edit')")
    @Log(title = "病历信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody skxMedicalRecord skxMedicalRecord)
    {
        return toAjax(skxMedicalRecordService.updateskxMedicalRecord(skxMedicalRecord));
    }

    /**
     * 删除病历信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxmedicalrecord:remove')")
    @Log(title = "病历信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{medicalRecordIds}")
    public AjaxResult remove(@PathVariable Long[] medicalRecordIds)
    {
        return toAjax(skxMedicalRecordService.deleteskxMedicalRecordByMedicalRecordIds(medicalRecordIds));
    }
}
